<?php
namespace app\backend\org;

use \app\backend\model\Menu;
use \think\Db;

class Kv
{
    static public function Kv($menu_id)
    {
        $language = input("lang","cn","htmlspecialchars");
        if($language=="cn"){
            $menu_name =  "menu_name_cn";
        }elseif($language=="en"){
            $menu_name =  "menu_name_en";
        }

        //默认值-1表示没有传参数或者参数错误
        if($menu_id== -1){
            return json([
                'code' => 2111,
                'message' => '传参错误',
            ]);
        }
        //判断是否是整型
        if(!is_numeric($menu_id)){
            return json([
                'code' => 2222,
                'message' => '不是数字',
            ]);
        }
        //判断参数是否大于0并且是整型
        if(intval($menu_id) < 0){
            return json([
                'code' => 2444,
                'message' => '不是整数并且小于0',
            ]);
        }

        //得到kv画面内容并查出颜色class
       // $menu=Menu::field('menu_id,$menu_name,back_img_url,color_class')->where(['delete_time',['is null'] ] );
        $menu = Db::query("select menu_id,$menu_name as menu_name,back_img_url,color_class from ls_menu where `delete_time` IS NULL and `menu_id`='".$menu_id."' ");
        //var_dump($menu);exit;
        return $menu;
    }
}